//
//  TestHeightViewControolerViewController.swift
//  statusBar_tabBar_safeArea_height
//
//  Created by 郭扬扬 on 2021/10/31.
//

import UIKit

class TestHeightViewControolerViewController: UIViewController {
    
    let topView = UIView.init()
    let bottomView = UIView.init()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor.white
        view.addSubview(topView)
        view.addSubview(bottomView)
    }
    
    override func viewDidLayoutSubviews() {
       //ios11，动态设置属性值
        if #available(iOS 11.0, *) {
            
            print(UIScreen.main.bounds)
            print(self.view.safeAreaLayoutGuide.layoutFrame)
            
            let safeAreaFram = self.view.safeAreaLayoutGuide.layoutFrame
            //状态栏
            kStatusBarHeight = safeAreaFram.origin.y
            //导航栏 + 状态栏
            kNavBarAndStatusBarHeight = kStatusBarHeight + kNavigationBarH
            //底部安全区
            kSafeAreaBottomH = kScreenH - safeAreaFram.size.height - kStatusBarHeight
            //tabbar + 底部安全区
            kTabBarAndSafeAreaH = kTabBarH + kSafeAreaBottomH

        } else {
            //ios11以前，就用默认的属性值
            
        }
        
        topView.backgroundColor = UIColor.red
        topView.frame = CGRect.init(x: 0, y: kStatusBarHeight, width: kScreenW, height: 100)
        
        bottomView.backgroundColor = UIColor.blue
        bottomView.frame = CGRect.init(x: 0, y: kScreenH - 100 - kSafeAreaBottomH, width: kScreenW, height: 100)
    }
    


}
